﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CoreLib.BusinessLogic;

namespace RKMSikraKulingram
{
    public partial class MainForm : Form
    {
        # region Data Members

        public CommonBLL commonBLL;
        private DevoteeDetails _devoteeDetails = null;
        private PersonDetailsPostForm _personDetailsPostForm = null;
        private PersonTransactionsForm _personTransactionForm = null;
        private SearchForm _searchForm = null;

        # endregion

        public MainForm()
        {
            InitializeComponent();
            this.FormClosing += (o, e) => { exitToolStripMenuItem_Click_1(o, e); };
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            ShowDevoteeDetailsForm();
        }

        private void devoteeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowDevoteeDetailsForm();
        }

        private void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            if (MessageBox.Show("Really Quit?", "Exit", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                Application.Exit();
            }
        }

        # region Private Methods

        private void ShowDevoteeDetailsForm()
        {
            _devoteeDetails = new DevoteeDetails();
            _devoteeDetails.DevoteeDetailsClosing += new EventHandler(_devoteeDetails_DevoteeDetailsClosing);
            _devoteeDetails.Show(this); 
        }

        void _devoteeDetails_DevoteeDetailsClosing(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you want to enter a new entry?", "Yes", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                ShowDevoteeDetailsForm();
            }
        }

        # endregion

        private void devoteeAddressListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _personDetailsPostForm = new PersonDetailsPostForm();
            _personDetailsPostForm.Show(this);
        }

        private void searchToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            _searchForm = new SearchForm();
            _searchForm.Show(this);
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PDFUtil.PersonDetailsPostToPDF.PersonDetailsPostSaveToPDF();
        }

        private void transactionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _personTransactionForm = new PersonTransactionsForm(0);
            _personTransactionForm.Show(this);
        }

        private void devoteeDetailsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _searchForm = new SearchForm();
            _searchForm.Show(this);
        }
    }
}
